/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace DaveSexton.DocProject.Sandcastle.ContentManagement
{
	[Serializable]
	internal class XmlCommentSectionContentItemAttributeDataCollection : ContentItemAttributeDataCollection
	{
		#region Public Properties
		#endregion

		#region Private / Protected
		private readonly string section;
		[NonSerialized]
		private readonly XmlElement element;
		private readonly ContentItem owner;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="XmlCommentSectionContentItemAttributeDataCollection" /> class.
		/// </summary>
		public XmlCommentSectionContentItemAttributeDataCollection(ContentItem owner, string section, XmlElement element)
		{
			if (owner == null)
				throw new ArgumentNullException("owner");

			if (string.IsNullOrEmpty(section))
				throw new ArgumentException(Resources.Errors.NullOrEmpty, "section");

			if (element == null)
				throw new ArgumentNullException("element");

			this.owner = owner;
			this.section = section;
			this.element = element;
		}
		#endregion

		#region Methods
		public override bool AllowNew
		{
			get
			{
				return true;
			}
		}

		public override object AddNew()
		{
			XmlCommentSectionContentItemAttributeData attribute = new XmlCommentSectionContentItemAttributeData(owner, section, element);
			
			Add(attribute);

			return attribute;
		}
		#endregion
	}
}
